Replay the live chat's provenance marker in review transcripts - #197
Draft
cpsievert wants to merge 5 commits into
Draft
Replay the live chat's provenance marker in review transcripts#197cpsievert wants to merge 5 commits into
cpsievert wants to merge 5 commits into
Conversation
The question list is server-rendered HTML outside shinychat's React tree, so bslib (Popper, container = body) can own tooltip positioning there. commons_answer_pill() gains a tooltip argument; the transcript keeps the inline CSS tooltip for now since bslib tooltips read template.content, which React-rendered message content never populates.
The trajectory review rebuilt provenance markers as a custom pill with a hand-rolled CSS tooltip, plus commons-chat.js to nudge the tooltip back inside the chat pane when it clipped. shinychat already solves this: its aside popover opens on hover/focus/click and is positioned by floating-ui through a portal, escaping clipping ancestors entirely. add_message_provenance() now appends the same <shiny-aside> string the live chat streams, as plain markdown joined with a blank line — the shape contents_shinychat() produces for a live-streamed aside — so the client's aside grouping turns it into the same marker users saw. A new include_cited flag on provenance_aside() keeps a visible marker for Cited answers in the review, which the live chat deliberately leaves bare. Deleted: commons-chat.js, commons_pill_tooltip(), and the .commons-tooltip CSS. Mixed message content (tool cards plus text) is flattened to a single markdown string per message: shinychat's static chat_ui() serializer folds mixed lists into one raw-HTML island, escaping the text and hiding it from aside grouping. The flattening keeps tool cards as routable custom elements; a shinychat-side fix would let us drop it.
The pill's visible text already announces the label, Bootstrap sets aria-describedby when the bslib tooltip shows the body, and the icon's alt text was a third copy. The icon is now decorative (alt="").
commons-chat.js is gone and the figs/ SVGs moved under www/commons-chat; refresh the files block and checksums accordingly. A full writeManifest() regeneration needs an environment with GitHub-sourced ellmer/shiny/shinychat installs; the packages section is unchanged.
Static chat_ui(messages =) folds mixed content (tool cards plus markdown text) into a single raw-HTML island, escaping the text and hiding it from shinychat's aside grouping. Mirror shinychat's own bookmark-restore idiom (client_set_ui): yield each message's contents from a coro generator through chat_append(), so every chunk is classified markdown vs HTML exactly as in the live stream. This drops the flatten_message_content() workaround along with its caveats (uncollected htmlwidget dependencies, unstyled thinking blocks), and the provenance aside now lands as a trailing markdown chunk, matching how a live-streamed aside arrives.
cpsievert
force-pushed
the
feat/review-provenance-aside
branch
from
August 27, 2026 23:52
d0dd412 to
811a465
Compare
|
Preview deployed to Connect ( Deployed from commit 811a465. |
|
Preview deployed to Connect ( Deployed from commit 811a465. |
cpsievert
marked this pull request as draft
August 28, 2026 00:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #173
The trajectory review now replays the exact provenance marker the user saw
in the live chat — same
<shiny-aside>, same popover — instead of renderinga custom pill with ~140 lines of hand-maintained tooltip CSS/JS, which this
PR deletes.
add_message_provenance()attachesprovenance_aside(tag, include_cited = TRUE)to each exchange's final answer as a trailing markdown chunk — the same
shape a live-streamed aside arrives in — so shinychat's own aside grouping
and floating-ui popover handle rendering and positioning.
include_cited(defaultFALSE, live behavior unchanged) keeps a visiblemarker for Cited answers in the review, which the live chat deliberately
leaves bare.
shinychat's React tree, where
<shiny-aside>would be inert — now with abslib::tooltip()(parent commit).Transcript rendering: replay, not static serialization
The transcript no longer goes through static
chat_ui(messages = ...). Thatpath folds mixed content (tool cards plus markdown text) into a single
raw-HTML island, escaping the text and hiding it from aside grouping —
contrary to shinychat's own docs ("strings are still interpreted as markdown
as long as they're not inside HTML").
Instead,
replay_transcript()mirrors shinychat's own bookmark-restoreidiom (
client_set_ui()): each message's contents are yielded from a corogenerator through
chat_append()once the chat element is bound, so everychunk is classified markdown vs HTML exactly as in the live stream. Tool
cards render as shinychat's native tool groups, htmlwidget dependencies are
collected per chunk, and thinking blocks keep their styling — none of which
held under static serialization. Exchange decorations are seeded after the
replay in the same flush, so message indices line up.
A static-
chat_ui()fix upstream in shinychat would still be welcome, butthis PR no longer depends on or works around that path.
Validation
test-trajectory-review.R,test-provenance.R, andtest-chat.Rpass,including coverage that transcripts carry the aside marker as a trailing
markdown chunk for A and B outcomes. Full suite left to CI.
Verified manually in a local review app with fabricated trajectories
covering every provenance outcome plus a
run_sqltool call (example appkept local, not in this PR):
working popovers (opaque background; the transparency issue seen with the
old hand-rolled CSS is gone).
message flow as the aside markers.
review pane and sidebar highlight, and sidebar clicks highlight the
corresponding transcript messages.
Browser/live-warehouse tests not run.